<template>
    <div>
        <template v-for="book in bookList">
            <mt-cell
                    :title="book.BookName"
                    :to="{name:'bookdetail',params:{id:book.BookId}}"
                    is-link
                    >
            </mt-cell>
        </template>

    </div>
</template>
<script>
    module.exports = {
        data(){
            return {
                bookList: [],
                metas: {
                    total: 0,
                    pageSize: 0,
                    current: 1
                }
            }
        },
        async created(){
            this.loadBook(1)
        },
        methods: {
            async loadBook(page){
                const rsp = await  axios.get("/prods?p=" + page)
                const {status, result ,metas} = rsp.data;
                if(status === 'success'){
                    this.bookList = result;
                    const {total, size, current} = metas;
                    this.metas.current = current;
                    this.metas.pageSize = size;
                    this.metas.total = total;
                }
            },
            changePage(page){
                this.loadBook(page)
            }

        }
    }
</script>